package com.autism.thread;

/**
 * 获取线程的名称
 * 1.getName（）
 * 2.先获取当前正在执行的线程，使用现称中的getName()获取线程名称
 */
public class ThreadDemo {

    public static void main(String[] args) {

        System.out.println(Thread.currentThread().getName());

        MyThread myThread = new MyThread();
        myThread.start();

        MyRunnable myRunnable = new MyRunnable();
        Thread thread = new Thread(myRunnable);
        thread.start();

        //thread
        new Thread() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println("autism=>" + i);
                }
            }
        }.start();

        //runnable
        new Thread(new MyRunnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println("suo=>" + i);
                }
            }
        }).start();
    }
}
